﻿<UserControl x:Class="CncConvProg.View.Controls.ProfileEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:DummyViewModels="clr-namespace:CncConvProg.ViewModel.EditWorkDialog.InputProfileViewModel;assembly=CncConvProg.ViewModel" xmlns:ValueConverter="clr-namespace:CncConvProg.View.ValueConverter" 
             xmlns:canvasP="clr-namespace:CncConvProg.View.Controls" xmlns:Resources="clr-namespace:MecPrev.Resources;assembly=MecPrev.Resources" mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="600"
             d:DataContext="{Binding Source={StaticResource viewModel}}"
             KeyDown="UserControl_KeyDown"
             >
    <UserControl.InputBindings>
        <KeyBinding Key="PageUp"
                    Modifiers="Alt"
                    Command="{Binding Path=GoToPrevMoveCmd}"
                    />
        <KeyBinding Key="PageDown"
                    Modifiers="Alt"
                    Command="{Binding Path=GoToNextMoveCmd}"
                    />
        <KeyBinding Key="A"
                    Modifiers="Alt"
                    Command="{Binding Path=AddEntityCmd}" CommandParameter="2"
                    />
        <KeyBinding Key="L"
                    Modifiers="Alt"
                    Command="{Binding Path=AddEntityCmd}" CommandParameter="1"
                    />
        <KeyBinding Key="Delete"
                    Modifiers="Alt"
                    Command="{Binding Path=DelEntityCmd}" CommandParameter="1"
                    />

    </UserControl.InputBindings>
    <UserControl.Resources>


        <ValueConverter:EnumToImageConverter x:Key="EIConverter"/>

        <DataTemplate DataType="{x:Type DummyViewModels:RawArcViewModel}">
            <canvasP:RawArcInputView />
        </DataTemplate>
        <DataTemplate DataType="{x:Type DummyViewModels:RawLineViewModel}">
            <canvasP:RawLineInputView />
        </DataTemplate>
        <DataTemplate DataType="{x:Type DummyViewModels:RawInitPointViewModel}">
            <canvasP:RawInitPointInputView />
        </DataTemplate>
        <!--<DummyViewModels:ProfileEditorViewModelLocator x:Key="viewModelLocator"  />-->
        <DummyViewModels:DummyProfileEditorViewModel x:Key="viewModel" />
    </UserControl.Resources>
    <!--<UserControl.DataContext>
        <Binding Source="{StaticResource viewModelLocator}" Path="ViewModel" />
    </UserControl.DataContext>-->

    <!--<UserControl.Resources>
        <DataTemplate DataType="{x:Type DummyViewModels:RawLineViewModel}">
            <canvasP:RawLineInputView />
        </DataTemplate>
        <DummyViewModels:DummyInputProfileViewModel x:Key="viewModel" />
    </UserControl.Resources>-->

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height=".3*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>


        <Border BorderThickness="2" Margin="5" Padding="5" CornerRadius="5" Grid.RowSpan="3" BorderBrush="BlanchedAlmond">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Image Source="pack://application:,,,/CncConvProg.View;component/Images/gui/ArrowUp.png" Width="32" DockPanel.Dock="Top"/>
                <!--<Image Source="pack://application:,,,/CncConvProg.View;component/Images/gui/keyPageUp.png" Width="32" Grid.Row="1"/>-->
                <ListView HorizontalAlignment="Center" Background="Transparent" BorderThickness="0" ItemsSource="{Binding Path=MoveListViewModels}" SelectedItem="{Binding Path=SelectedMoveViewModel}" Grid.Row="2" Grid.Column="1" Grid.RowSpan="1" DockPanel.Dock="Top">
                    <ListView.Resources>
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrush}" Color="Transparent" />
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightColor}" Color="Transparent" />
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightColorKey}" Color="Transparent" />

                        <!--<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />-->
                        <Style x:Key="borderStyle" TargetType="{x:Type Border}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding   RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}},    Path=IsSelected}" Value="True">
                                    <Setter Property="Border.BorderBrush" Value="Green"/>
                                    <Setter Property="Border.Background" Value="LemonChiffon"/>
                                    <Setter Property="Border.BorderThickness" Value="1"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ListView.Resources>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <Border Style="{StaticResource ResourceKey=borderStyle}" CornerRadius="5" BorderBrush="Black" BorderThickness=".5" Padding="5" Margin="2">
                                <Image Width="25" Height="25" Source="{Binding Path=Orientation, 
                        Converter={StaticResource EIConverter}}" />
                            </Border>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                <Image Source="pack://application:,,,/CncConvProg.View;component/Images/gui/ArrowDown.png" Width="32" DockPanel.Dock="Bottom" Grid.Row="4"/>
                <!--<Image Source="pack://application:,,,/CncConvProg.View;component/Images/gui/keyPageDown.png" Width="50" Height="50" DockPanel.Dock="Bottom" Grid.Row="3"/>-->

            </Grid>
        </Border>

        <ContentControl Content="{Binding Path=SelectedMoveViewModel}" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Grid.RowSpan="2"/>
        <Border Grid.Column="3" Grid.ColumnSpan="1" Grid.RowSpan="3" BorderThickness="2" CornerRadius="5" BorderBrush="BlanchedAlmond" Margin="5">
            <StackPanel Orientation="Vertical" Grid.Column="3" Grid.ColumnSpan="2" Margin="10">
                <Image Source="pack://application:,,,/CncConvProg.View;component/Images/gui/keyAlt.png" Width="40" VerticalAlignment="Top"/>
                <TextBlock Text="+" FontSize="40" VerticalAlignment="Top" FontWeight="Bold"/>
                <StackPanel Orientation="Horizontal" Margin="0,0">
                    <Image Source="pack://application:,,,/CncConvProg.View;component/Images/gui/keyL.png" Width="40"/>
                    <Button Command="{Binding Path=AddEntityCmd}" CommandParameter="1" Content="{x:Static Resources:EditWorkRes.AddLine}" Height="40" Width="Auto" Margin="3" />
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0,0">
                    <Image Source="pack://application:,,,/CncConvProg.View;component/Images/gui/keyA.png" Width="40"/>
                    <Button Command="{Binding Path=AddEntityCmd}" CommandParameter="2" Content="{x:Static Resources:EditWorkRes.AddArc}" Height="40" Width="Auto" Margin="3" />
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0,0">
                    <Image Source="pack://application:,,,/CncConvProg.View;component/Images/gui/keyCanc.png" Width="40"/>
                    <Button Command="{Binding Path=DelEntityCmd}" Content="{x:Static Resources:EditWorkRes.Delete}" Height="40" Width="Auto" Margin="3" />
                </StackPanel>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>

    
    